import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
import { dateTransformer } from '../../../../common/utils';

@Entity('refund_record', {
  comment: '退款记录表',
})
export class RecordEntity {
  @PrimaryGeneratedColumn({ type: 'bigint', name: 'id', comment: '记录ID' })
  public id: number;

  @Column({ type: 'bigint', name: 'order_id', default: null, comment: '订单ID' })
  public orderId: number;

  @Column({ type: 'varchar', name: 'order_no', default: '', comment: '订单编号' })
  public orderNo: string;

  @Column({ type: 'varchar', name: 'out_trade_no', default: '', comment: '商户订单号' })
  public outTradeNo: string;

  @Column({ type: 'varchar', name: 'transaction_id', default: '', comment: '微信支付订单号' })
  public transactionId: string;

  @Column({ type: 'varchar', name: 'out_refund_no', default: '', comment: '商户退款单号' })
  public outRefundNo: string;

  @Column({ type: 'varchar', name: 'refund_id', default: '', comment: '微信退款单号' })
  public refundId: string;

  @Column({ type: 'int', name: 'refund_fee', default: null, comment: '退款金额(分)' })
  public refundFee: number;

  @Column({ type: 'int', name: 'total_fee', default: null, comment: '订单总金额(分)' })
  public totalFee: number;

  @Column({ type: 'varchar', name: 'refund_status', default: '', comment: '退款状态' })
  public refundStatus: string;

  @Column({ type: 'varchar', name: 'refund_desc', default: '', comment: '退款原因' })
  public refundDesc: string;

  @Column({ type: 'datetime', name: 'refund_success_time', default: null, comment: '退款成功时间' })
  public refundSuccessTime: Date;

  @CreateDateColumn({ type: 'datetime', name: 'create_time', default: null, transformer: dateTransformer, comment: '创建时间' })
  public createTime: Date;

  @UpdateDateColumn({ type: 'datetime', name: 'update_time', default: null, transformer: dateTransformer, comment: '更新时间' })
  public updateTime: Date;
}
